package com.carrent.demo.Controller;

import com.carrent.demo.Domain.Contract;
import com.carrent.demo.Service.ContractService;
import com.carrent.demo.Utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/contract")
public class    ContractController {
    @Autowired
    ContractService contractService;
    //获取合同信息
    @GetMapping("/page")
    public R getPage(Integer page,Integer pageSize,String name) throws ParseException {
        final List<Contract> page1 = contractService.getPage((page - 1) * pageSize, pageSize, name);
        final Integer count = contractService.getCount(name);
        return  R.success(page1,count);
    }
    //删除合同信息
    @DeleteMapping
    public  R deleteContract(@RequestParam(value = "ids") List<String> ids)
    {
        for(String s : ids)
        {
            contractService.deleteContract(s);
        }
        return R.success("");
    }



}